home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / Globals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  2.7 KB  |  120 lines  |  [TEXT/KAHL]

  1. /*    look at this, check for nil?    */
  2.  
  3. /* Globals.c */    /*    C14 Calculator */
  4. #include "Globals.h"
  5. /*#include "PredatorPrey.h"*/
  6.  
  7. /*Standard vars:*/
  8.  
  9. Boolean            quittingTime;
  10. short            kkk;
  11. EventRecord        curEvent;
  12. WindowPtr        curWindow;
  13. WindowPtr        altCurWindow;
  14. WinInfoPtr        cur;
  15. WinInfoPtr        altCur;
  16. SysConfigRec    sysConfig;
  17. WinInfoRec        noCur;
  18. Rect            viewRect;                        /* for calculations of TE areas        */
  19. Point            workPoint;                        /* work variable                    */
  20. short            myMouseWhere;                    /* location (not Point) of mouse    */
  21. Boolean            workBoolean;                    /* work variable                    */
  22. short            WorkRetCode;                    /* work return code                    */
  23. WindowPtr        workWindowPtr;                    /* pointer from FindWindow            */
  24. long            worklong;                        /* work variable                    */
  25. RgnHandle        workRegionH;                    /* work handle for TE redraw        */
  26. Rect            destRect;                        /* for calculations of TE areas        */
  27. short            windSub;                        /* subscript for window table        */
  28. Point            helpCell = {0, 0};                /* cell for List Manager            */
  29. short            helpPrev = -1;                    /* previously selected help item    */
  30. Rect            workRect;                        /* work variable                    */
  31.  
  32. void    GlobalsSeg()    {}
  33.  
  34. /*----------*/
  35. void InitGlobals (void)
  36. {
  37.     curWindow = nil;
  38.     
  39.     noCur.text = nil;
  40.     noCur.vScroll = nil;
  41.     noCur.hScroll = nil;
  42.     noCur.pFileNum = 0;
  43.     noCur.qFileNum = 0;
  44.     noCur.volNum = 0;
  45.     noCur.pDirty = false;
  46.     noCur.qDirty = false;
  47.     noCur.windowKind = noWindow;
  48.     //noCur.rText = nil;
  49.  
  50.     cur = &noCur;
  51.     
  52. } /*InitGlobals*/
  53.  
  54. /*----------*/
  55. void SetInfo (WindowPtr        window)
  56. {
  57.     WinInfoPtr        infoPtr;
  58.  
  59.     if (window != curWindow) {
  60.         curWindow = window;
  61.         if (curWindow != nil) {
  62.             infoPtr = (WinInfoPtr) GetWRefCon (curWindow);
  63.             cur = infoPtr;
  64.         } else {
  65.             cur = &noCur;
  66.         }
  67.     }
  68. } /*SetInfo*/
  69.  
  70. /*void SetSaveInfo (WindowPtr        window)*/
  71. /*{*/
  72. /*    WinInfoPtr        infoPtr;*/
  73. /**/
  74. /*    if (window != altCurWindow) {*/
  75. /*        altCurWindow = window;*/
  76. /*        if (altCurWindow != nil) {*/
  77. /*            infoPtr = (WinInfoPtr) GetWRefCon (curWindow);*/
  78. /*            altCur = infoPtr;*/
  79. /*        } else {*/
  80. /*            altCur = &noCur;*/
  81. /*        }*/
  82. /*    }*/
  83. /*} /*SetSaveInfo»*/
  84.  
  85. /*----------*/
  86. void SetNewInfo (WindowPtr        window)
  87. {
  88.     WinInfoPtr        infoPtr;
  89.  
  90.     infoPtr = (WinInfoPtr) NewPtr (sizeof (WinInfoRec));/*    look at this, check for nil?    */
  91.     SetWRefCon (window, (long) infoPtr);
  92.     SetInfo (window);
  93. } /*SetNewInfo*/
  94.  
  95. /*----------*/
  96. /*void SetAltInfo (WindowPtr        window)*/
  97. /*{*/
  98. /*    WinInfoPtr        infoPtr;*/
  99. /*    */
  100. /*    infoPtr = (WinInfoPtr) NewPtr (sizeof (WinInfoRec));*/
  101. /*    SetWRefCon (window, (long) infoPtr);*/
  102. /*    SetSaveInfo(window);*/
  103. /*} /*SetAltInfo*/
  104.  
  105. /*----------*/
  106. void DiscardInfo (WindowPtr        window)
  107. {
  108.     WinInfoPtr        infoPtr;
  109.  
  110.     if (window == curWindow) {
  111.         SetInfo (nil);
  112.     }
  113.     infoPtr = (WinInfoPtr) GetWRefCon (window);
  114.     DisposPtr ((Ptr) infoPtr);
  115.     HideWindow (window);
  116.     DisposeWindow (window);
  117. } /*DiscardInfo*/
  118.  
  119. /* Globals */
  120.